package cn.hloger.spider;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.ConfigurableEnvironment;

@SpringBootApplication
public class SpiderApplication {

    public static void main(String[] args) {
        ConfigurableApplicationContext context =
                SpringApplication.run(SpiderApplication.class, args);
        printInfo(context);
    }


    private static void printInfo(ConfigurableApplicationContext context) {
        ConfigurableEnvironment env = context.getEnvironment();
        String port = env.getProperty("server.port");
        String active = env.getProperty("spring.profiles.active");
        String hostname = env.getProperty("spring.cloud.client.hostname");
        String ip = env.getProperty("spring.cloud.client.ip-address");
        System.out.println("==========================================================================");
//       \033[31m 之后的文字是红色, \033[0m之后的是黑色
        System.out.println("应用已启动,hostname: \033[31m" + hostname + "\033[0m");
        System.out.println("active配置: \033[31m" + active + "\033[0m");
        System.out.println("访问地址,本地： http://localhost:" + port);
        System.out.println("访问地址,外网： http://" + ip + ":" + port);
        System.out.println("==========================================================================");
    }

}
